package com.ui.zhong.webview.webviewproc.chromeclient

import android.util.Log
import android.webkit.ConsoleMessage
import android.webkit.WebChromeClient
import android.webkit.WebView
import com.ui.zhong.webview.WebViewCallback

class CustomWebChromeClient(val callback: WebViewCallback?) : WebChromeClient() {
    private val TAG = "CustomWebChromeClient"
    override fun onReceivedTitle(view: WebView?, title: String) {
        super.onReceivedTitle(view, title)
        Log.d(TAG, "webview: $view ,title: $title")
        callback?.updateTitle(title)
    }

    override fun onConsoleMessage(consoleMessage: ConsoleMessage?): Boolean {
        if (consoleMessage != null) {
            Log.d(TAG, "onConsoleMessage: ${consoleMessage.message()}")
        }
        return super.onConsoleMessage(consoleMessage)
    }

}